export keda_version=$(
	curl -sL \
		https://api.github.com/repos/kedacore/keda/releases/latest |
		jq -r '.tag_name | ltrimstr("v")'
)
export http_add_on_version=$(
	curl -sL \
		https://api.github.com/repos/kedacore/http-add-on/releases/latest |
		jq -r '.tag_name | ltrimstr("v")'
)

echo "keda: ${keda_version}"
echo "keda_http_add_on_version: ${http_add_on_version}"

export keda="keda-${keda_version}.tgz"
export kedaaddonshttp="keda-add-ons-http-${http_add_on_version}.tgz"
export proxy="https://ghproxy.net/"
export namespace="keda-system"

wget ${proxy}https://kedacore.github.io/charts/${keda}
wget ${proxy}https://kedacore.github.io/charts/${kedaaddonshttp}

# https://kedacore.github.io/charts/keda-add-ons-http-0.10.0.tgz

# wget https://kedacore.github.io/charts/${keda}
# wget https://kedacore.github.io/charts/${kedaaddonshttp}

helm upgrade --create-namespace --install keda -n ${namespace} ${keda}  #--set global.registry="ghcr.nju.edu.cn/keda"
helm upgrade --create-namespace --install kedahttp -n ${namespace} ${kedaaddonshttp} --values http.yaml

rm -rf ${keda}
rm -rf ${keda_dashboard}
